package rpd.mapper;

import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import rpd.model.TbUser;
import rpd.model.TbUserExample;
import rpd.model.TbUserKey;

public interface TbUserMapper {
    long countByExample(TbUserExample example);

    int deleteByExample(TbUserExample example);

    @Delete({
        "delete from tb_user",
        "where user_id = #{userId,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(TbUserKey key);

    @Insert({
        "insert into tb_user (user_id, user_name, ",
        "user_identity, user_email, ",
        "user_phone, user_password, ",
        "user_status, user_last_login_time, ",
        "user_create_time)",
        "values (#{userId,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR}, ",
        "#{userIdentity,jdbcType=VARCHAR}, #{userEmail,jdbcType=VARCHAR}, ",
        "#{userPhone,jdbcType=VARCHAR}, #{userPassword,jdbcType=VARCHAR}, ",
        "#{userStatus,jdbcType=VARCHAR}, #{userLastLoginTime,jdbcType=TIMESTAMP}, ",
        "#{userCreateTime,jdbcType=TIMESTAMP})"
    })
    int insert(TbUser record);

    int insertSelective(TbUser record);

    List<TbUser> selectByExample(TbUserExample example);

    @Select({
        "select",
        "user_id, user_name, user_identity, user_email, user_phone, user_password, user_status, ",
        "user_last_login_time, user_create_time",
        "from tb_user",
        "where user_id = #{userId,jdbcType=VARCHAR}"
    })
    @ResultMap("rpd.mapper.TbUserMapper.BaseResultMap")
    TbUser selectByPrimaryKey(TbUserKey key);

    int updateByExampleSelective(@Param("record") TbUser record, @Param("example") TbUserExample example);

    int updateByExample(@Param("record") TbUser record, @Param("example") TbUserExample example);

    int updateByPrimaryKeySelective(TbUser record);

    @Update({
        "update tb_user",
        "set user_name = #{userName,jdbcType=VARCHAR},",
          "user_identity = #{userIdentity,jdbcType=VARCHAR},",
          "user_email = #{userEmail,jdbcType=VARCHAR},",
          "user_phone = #{userPhone,jdbcType=VARCHAR},",
          "user_password = #{userPassword,jdbcType=VARCHAR},",
          "user_status = #{userStatus,jdbcType=VARCHAR},",
          "user_last_login_time = #{userLastLoginTime,jdbcType=TIMESTAMP},",
          "user_create_time = #{userCreateTime,jdbcType=TIMESTAMP}",
        "where user_id = #{userId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(TbUser record);
}